package offer;

public class offer13 {
}
class Solution13 {
    public  static int movingCount(int m, int n, int k) {
        int [][]board = new int[m][n];
        boolean [][]bd = new boolean[m][n];
        int count=0;
        for (int i = 0; i <m ; i++) {
            for (int j = 0; j < n; j++) {

                if(bd[i][j]==false&&cheak(i,j,k))
                {
                    count++;
                    bd[i][j] = true;
                }
            }
        }
    return count;
    }

    private static boolean cheak(int i, int j, int k) {
        int num1 = i%10;
        int num2 = i/10;
        int num3 = j%10;
        int num4 = j/10;
        if((num1+num3+num2+num4)<=k)
        return true;
        else return false;
    }
    public static void main(String[] args) {
        movingCount(16, 8, 4);
    }
}